import { ref } from 'vue';
import { defineStore } from 'pinia';
import { constants } from '@/config/index.js';
import { langs } from '@/locale/language.js';

export const setupsStore = defineStore('setups', () => {
	const langSys = uni.getLocale();    // 语言 
	const isPop = ref(false);           // 是否pop弹窗
	const lastRoute = ref();            // 记录上一次路由URL           
	const scenarioInfo = ref({
		scenario_id: constants.SCENQA,
	});           // 场景ID
	const langInfo = ref(langs.find(item => item.code == langSys) || langs[0]);
	
	function setPop(val) {
		isPop.value = val;
	}
	
	function setLangInfo(val) {
		langInfo.value = val;
	}
	
	function setLastRoute(val) {
		lastRoute.value = val;
	}
	
	function setScenario(val) {
		scenarioInfo.value = Object.assign({}, val);
	}

	return { 
		isPop, setPop,
		scenarioInfo, setScenario,  
		langInfo, setLangInfo,
		lastRoute, setLastRoute
	};
});